package com.webmuseum.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.ListBox;

public class SearchComposite extends Composite
{

	public SearchComposite() {
		
		VerticalPanel mCompositePanel = new VerticalPanel();
		initWidget(mCompositePanel);
		mCompositePanel.setSize("635px", "382px");
		
		FlexTable mFlexComposite = new FlexTable();
		mCompositePanel.add(mFlexComposite);
		mFlexComposite.setSize("635px", "381px");
		
		ScrollPanel mSearchPanel = new ScrollPanel();
		mFlexComposite.setWidget(0, 0, mSearchPanel);
		mSearchPanel.setSize("630px", "107px");
		
		FlexTable mFlexSearch = new FlexTable();
		mSearchPanel.setWidget(mFlexSearch);
		mFlexSearch.setSize("100%", "106px");
		
		TextBox mSearchBox = new TextBox();
		mSearchBox.setText("Insert text here");
		mSearchBox.setMaxLength(100);
		mFlexSearch.setWidget(0, 0, mSearchBox);
		mSearchBox.setWidth("259px");
		
		ListBox mComboBox = new ListBox();
		mFlexSearch.setWidget(0, 1, mComboBox);
		mComboBox.setWidth("127px");
		
		PushButton mSearchBtn = new PushButton("Search");
		mFlexSearch.setWidget(0, 2, mSearchBtn);
		mSearchBtn.setSize("110px", "20px");
		mFlexSearch.getCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
		mFlexSearch.getCellFormatter().setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_MIDDLE);
		mFlexSearch.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
		mFlexSearch.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
		mFlexSearch.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
		mFlexSearch.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
		
		ScrollPanel mResultPanel = new ScrollPanel();
		mFlexComposite.setWidget(1, 0, mResultPanel);
		mResultPanel.setHeight("247px");
		
		CellTable<Object> mResultTable = new CellTable<Object>();
		mResultPanel.setWidget(mResultTable);
		mResultTable.setSize("100%", "247px");
		
		//Init Criteria
		mComboBox.addItem("Criteria One");
		mComboBox.addItem("Criteria Two");
		mComboBox.addItem("Criteria Three");
		
		//Init result table
		//Set Columns
		TextColumn<Object> nameColumn = new TextColumn<Object>() {
		      @Override
		      public String getValue(Object object) {
		        return object.toString();
		      }
		 };
		 mResultTable.addColumn(nameColumn, "Record Number");

		 TextColumn<Object> titleColumn = new TextColumn<Object>() {
			 @Override
			 public String getValue(Object object) {
				 //return object.getTitle();
				 return object.toString(); //<- WRONG
			 }
		 };
		 mResultTable.addColumn(titleColumn, "Record Title");
		 
		// Set the total row count. This isn't strictly necessary, but it affects
		// paging calculations, so its good habit to keep the row count up to date.
		//mResultTable.setRowCount(mResultList.size(), true);

		// Push the data into the widget.
		//mResultTable.setRowData(0, mResultList);
		 
		 
		 
	}

}
